<?php

/**
 * @Author: king
 * @Date:   2019-05-04 17:44:43
 * @Last Modified by:   king
 * @Last Modified time: 2019-05-12 11:46:02
 */

namespace App\Models\Api;
use App\Exceptions\ApiException;
use App\Models\Api\Base;
use Cache;
class LanmeiFortune extends Base
{
    protected $table = 'astro_fortune';

    public function saveFortune($map = [], $id = 0)
    {
        if ($id === 0) {
            try {

                $this->insert($map);
            } catch (\Exception $e) {
               throw new ApiException('运势记录入库失败', config('code.error'));
            }
        } else {
            try {

                $this->update($map, ['id' => $id]);
            } catch (\Exception $e) {
                throw new ApiException('运势记录更新失败', config('code.error'));
            }
        }

        return true;

    }

}
